//
// Tip.js
// Shows a TIP javascript box.
//
//
// Simple Javascript filter framework. Uses JQuery and PHP.JS.
// 
// Usage: put the tag filter="negative_number" (for instance) and
// filter.js will do the magic.
// 
// To create a tip just add the "tip" attribute to your
// html element.
//
// To style the tip, just create your own css for: div.dddtip
//
function ddd_tip() {
  $("*[tip]").each(function() {
    var tip             = $(this).attr("tip");
    var element_id      = $(this).attr("id");
    var element_offset  = $(this).offset();
    var element_width   = $(this).width();
    var div_tip_id      = 'div_tip_' + element_id;
    
    // mouseover
    $(this).mouseover(function(event) {
      // Adds the div with info
      if ($("#" + div_tip_id).length == 0) {
        $(this).after("<div style='position: absolute; display: none;' id='" + 
                      div_tip_id + "' > " + 
                      tip + 
                      "</div>");
      }

      // Positions the div
      $("#" + div_tip_id).css({
        "left": (event.pageX + 5) + "px",
        "top": (event.pageY) + "px"
      });

      // Adds the css class to be used.
      $("#" + div_tip_id).addClass("dddtip");

      $("#" + div_tip_id).show("slow");
    });

    // Mouseout
    $(this).mouseout(function() {
      $("#" + div_tip_id).remove();
    });

  });
}


